package com.lzy.huijinjiazu.mvp.ui.activity;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.FrameLayout;

import com.gyf.barlibrary.ImmersionBar;
import com.jess.arms.base.BaseActivity;
import com.jess.arms.di.component.AppComponent;
import com.lzy.huijinjiazu.R;
import com.lzy.huijinjiazu.di.component.DaggerFeedbackCenterComponent;
import com.lzy.huijinjiazu.di.module.FeedbackCenterModule;
import com.lzy.huijinjiazu.mvp.contract.FeedbackCenterContract;
import com.lzy.huijinjiazu.mvp.presenter.FeedbackCenterPresenter;
import com.lzy.huijinjiazu.mvp.ui.adapter.FeedbackCenterAdapter;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;


public class FeedbackCenterActivity extends BaseActivity<FeedbackCenterPresenter> implements FeedbackCenterContract.View {


    @BindView(R.id.fl_title)
    FrameLayout mFlTitle;
    @BindView(R.id.rv_list)
    RecyclerView mRvList;
    private FeedbackCenterAdapter mAdapter;

    @Override
    public void setupActivityComponent(AppComponent appComponent) {
        DaggerFeedbackCenterComponent //如找不到该类,请编译一下项目
                .builder()
                .appComponent(appComponent)
                .feedbackCenterModule(new FeedbackCenterModule(this))
                .build()
                .inject(this);
    }

    @Override
    public int initView(Bundle savedInstanceState) {
        return R.layout.activity_feedback_center; //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0
    }

    @Override
    public void initData(Bundle savedInstanceState) {
        initRecyclerView();
        initData();
    }

    private void initRecyclerView() {
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
        linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
        mRvList.setLayoutManager(linearLayoutManager);
        mRvList.setHasFixedSize(true);
        mAdapter = new FeedbackCenterAdapter();
        mRvList.setAdapter(mAdapter);
    }

    private void initData() {
        List<String> data = new ArrayList<>();
        for (int i = 0; i < 6; i++) {
            data.add("");
        }
        mAdapter.setNewData(data);
    }

    @Override
    protected void initImmersionBar() {
        super.initImmersionBar();
        mImmersionBar.setTitleBarMarginTop(this, mFlTitle);
    }

    @OnClick(R.id.iv_back)
    public void onViewClicked() {
        finish();
    }
}
